package com.uinnova.visualbase.controller;

import com.uinnova.visualbase.dao.Models;
import com.uinnova.visualbase.dao.Scene;
import com.uinnova.visualbase.mapper.ModelsMapper;
import com.uinnova.visualbase.service.ModelsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;

@Controller
public class ModelController {
    @Autowired
    public ModelsService modelsService;

//   修改时保存场景对象信息
    @ResponseBody
    @RequestMapping("/saveModels")
    public int saveModels(@RequestBody Models models, HttpServletResponse resp){
//        保存的时候id相同的就修改，不同的保存
//        先根据传过来的id查询数据表中有没有，有，修改，没有，添加
          modelsService.queryAll(models);
//        modelsMapper.addModels(models);
//        System.out.println(models);
        return 1;

    }

//    返回自己创建的对象的信息
    @ResponseBody
    @RequestMapping(value="/myModels")
    public ArrayList<Models> myModels(int sId){
        return modelsService.queryModelsBySid(sId);
    }


}
